﻿namespace com.stifel.Extensions.PropertyChangedEventHandlerExtensions
{
    using System;
    using System.ComponentModel;

    public static class PropertyChangedEventHandlerExtensions
    {
        #region Methods

        /// <summary>
        /// Attempt to raise the specified event in a recognized safe manner.
        /// </summary>
        /// <param name="a">Represents the method that will handle an event that has no event data.</param>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">Event data.</param>
        public static void TryRaise( this PropertyChangedEventHandler a, object sender, PropertyChangedEventArgs args )
        {
            PropertyChangedEventHandler temp = a;
            if ( a != null )
                a( sender, args );
        }

        /// <summary>
        /// Attempt to raise the specified event asynchronously in a recognized safe manner.
        /// </summary>
        /// <param name="a">Represents the method that will handle an event.</param>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">An instance of type PropertyChangedEventArgs.</param>
        public static void TryRaiseAsync( this PropertyChangedEventHandler a, object sender, PropertyChangedEventArgs args )
        {
            AsyncPropertyChangedEventHandler.TryRaise( sender, a, args );
        }

        #endregion Methods
    }
}